﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Kaleidoscope._Default" Title="Virtual Kaleidoscope" %>
<%@ Register TagPrefix="uc" TagName="DynamicImage" Src="DynamicImage.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">

    <title title="Virtual Kaleidoscope"></title>
    <script language="javascript">
        var imgRe = /^.+\.(jpg|jpeg|gif|png)$/i;
        function viewImage(pathField, viewName) {
            var path = pathField.value;
            if (path.search(imgRe) == -1) {
                alert("JPG,PNG and GIFs only!");
            }
            else {
                document[viewName].src = "file://" + path;
                var img = new Image();
                img.src = "file://" + path;
                document.write(img.width + " pixels wide " + img.height + " pixels high<br>" + "img src="+img.src+"><br>"); 
            }
        }
    </script>
</head>
<body>


<asp:Label ID="labelMessage" runat="server" Text="Choose picture file to upload:" />
<uc:DynamicImage runat="server" />
<div><asp:Label runat="server" ID="messageLabel" Visible="false"></asp:Label>
</div>

<form name="checkImage" >
    <input type="file" name = "myImage" onchange="viewImage(document.checkImage.myImage,'replaceMe')" />
    <uc:DynamicImage ID="DynamicImage1" runat="server" EnableViewState="false" />
</form>

    <form id="mainForm" runat="server">
    <asp:ScriptManager ID="ScriptManagerMainForm" runat="server" />
    <asp:UpdatePanel ID="UpdatePanelMainForm" runat="server">
    <Triggers>
    <asp:PostBackTrigger ControlID="buttonUpload" />
    </Triggers>
        <ContentTemplate>
            <asp:FileUpload ID="fileUploader" runat="server" />
            <asp:Button ID="buttonUpload" runat="server" Text="Upload"
                onclick="buttonUpload_Click" />
                <uc:DynamicImage runat="server" EnableViewState="false" />
                <asp:Label Text="Just a label" runat="server" />
        </ContentTemplate>
    </asp:UpdatePanel>    
    </form>
    
</body>
</html>
